<template>
  <div class="container">
      <ul class="title">
          <li :class="{'title-checked': currentTabNum == 0}" @click="activeTab(0)">全部</li>
          <li :class="{'title-checked': currentTabNum == 1}" @click="activeTab(1)">综合</li>
          <li :class="{'title-checked': currentTabNum == 2}" @click="activeTab(2)">价格</li>
      </ul>
      <div class="classify-wrapper">
          <div class="classify-nav" ref="classifyNav">
              <ul class="classify-nav-list">
                  <li class="classify-nav-item" v-for="(item, index) in 100" :key="index" :class="{'classify-nav-item-actived': currentNavNum == index}" @click="activeNavItem(index)">
                      全部{{item}}
                  </li>
              </ul>
          </div>
          <div class="classify-goods" ref="classifyGoods">
              <ul class="classify-goods-list">
                  <li class="classify-goods-item" v-for="(item, index) in 20" :key="index">
                      <img class="classify-goods-img" src="../../static/img/WechatIMG292.png" alt="">
                      <div class="classify-goods-con">
                          <h4 class="classify-goods-name">高夫男士护肤品套装洗面控油补水保湿去黑头洁</h4>
                          <div class="classify-goods-feture">500ml</div>
                          <div class="classify-goods-price">￥
                              <span class="boldNum">{{'50.08'|getInter}}.</span>
                              <span>{{'50.08'|getDot}}</span>
                          </div>
                      </div>
                  </li>
              </ul>
          </div>
      </div>
  </div>
</template>

<script>
import BScroll from 'better-scroll'
export default {
    data(){
        return {
            currentNavNum: 0,
            currentTabNum: 0
        }
    },
    methods: {
        activeNavItem(index) {
            this.currentNavNum = index;
        },
        activeTab(index) {
            this.currentTabNum = index;
        }
    },
    filters:{
        getInter(val) {
            return val.split('.')[0]
        },
        getDot(val) {
            return val.split('.')[1]
        }
    },
    mounted() {
       let classifyNav = document.querySelector('.classify-nav');
       this.nav = new BScroll(classifyNav, {
           click: true
       });
       let classifyGoods = this.$refs.classifyGoods;
       this.goods = new BScroll(classifyGoods, {
           
       })
    }
}

</script>
<style>
.title {
    height: 0.44rem;
    font-size: 0.18rem;
    line-height: 0.44rem;
    position: relative;
    display: flex;
    justify-content: space-around;
}
.title::after {
    position: absolute;
    content:  "";
    left: 0;
    bottom: 0;
    width: 100%;
    border-top: 1px solid #ccc;
    transform: scale(1, 0.5);
}
.title li{
    font-size: 0.14rem;
    color: #333;
    position: relative;
    -webkit-tap-highlight-color: rgba(0,0,0,0)
}
.title-checked::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: 0;
    border-bottom: 2px solid #dd3333; 
    width: 100%;
}
.classify-wrapper {
    position: absolute;
    top: 0.44rem;
    bottom: 0;
    width: 100%;
    display: flex;
    overflow: hidden;
}
.classify-nav {
    width: 0.9rem;
    background: #f2f2f2;
    position: relative;
}
.classify-nav::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    border-right: 1px solid #ccc;
    transform: scale(0.5, 1)
}
.classify-nav-list {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.classify-nav-item {
    height: 0.44rem;
    line-height: 0.44rem;
    width: 100%;
    background: #f2f2f2;
    position: relative;
    box-sizing: border-box;
}

.classify-nav-item::after {
    content: "";
    position: absolute;
    bottom: 0;
    width: 100%;
    left: 0;
    border-bottom: 1px solid #ccc; 
    transform: scale(1, 0.5)

}
.classify-nav-item-actived {
    background: #fff;
    width: 100%;
}
.classify-nav-item-actived::before {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    border-right: 1px solid #fff;
    transform: scale(0.5, 1)
}
.classify-goods {
    flex: 1;
    padding: 0 0.14rem;
}
.classify-goods-list {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}
.classify-goods-item {
    height: 1rem;
    display: flex;
    align-items: center;
    position: relative;
}
.classify-goods-item::after {
    content: "";
    position: absolute;
    left: 0;
    width: 100%;
    bottom: 0;
    border-top: 1px solid #f1f2f6;
    transform: scale(1, 0.5);
}
.classify-goods-img {
    width: 0.8rem;
    height: 0.8rem;
    margin-right: 0.1rem;
}
.classify-goods-con {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: space-between;
}
.classify-goods-name {
    text-align: left;
    font-size: 0.14rem;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
}
.classify-goods-feture {
    padding: 0.03rem 0 0.06rem 0;
    font-size: 0.12rem;
    color: #999;
}
.classify-goods-price {
    font-size: 0.12rem;
    color: #dd3333;
}
.boldNum {
    font-size: 0.16rem;
    margin-right: -0.04rem;
}
</style>